package com.ruoyi.web.controller.modules;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.web.domain.screen.BigScreen;
import com.ruoyi.web.pojo.dto.screen.BigScreenRep;
import com.ruoyi.web.pojo.request.screen.BigScreenAdd;
import com.ruoyi.web.service.screen.IBigScreenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 大屏配置Controller
 * 
 * @author zq
 * &#064;date  2024-01-15
 */
@Api(tags = "大屏配置")
@RestController
@RequestMapping("/screen")
public class BigScreenController extends BaseController
{

    private final IBigScreenService bigScreenService;

    public BigScreenController(IBigScreenService bigScreenService) {
        this.bigScreenService = bigScreenService;
    }

    /**
     * 查询大屏配置列表
     */
    @ApiOperation("查询大屏配置列表")
    @GetMapping("/list")
    public TableDataInfo<BigScreenRep> list(BigScreen bigScreen)
    {
        startPage();
        List<BigScreenRep> list = bigScreenService.selectBigScreenList(bigScreen);
        return getDataTable(list);
    }

    /**
     * 获取大屏配置详细信息
     */
    @ApiOperation("获取大屏配置详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bigScreenService.selectBigScreenById(id));
    }
    /**
     * 新增大屏配置
     */
    @ApiOperation("新增大屏配置")
    @PostMapping
    public AjaxResult add(@RequestBody BigScreenAdd bigScreen)
    {
        SecurityUtils.getUserId();
        return toAjax(bigScreenService.insertBigScreen(BigScreen.toBigScreen(bigScreen)));
    }

    /**
     * 修改大屏配置
     */
    @ApiOperation("修改大屏配置")
    @PutMapping
    public AjaxResult edit(@RequestBody BigScreenAdd bigScreen)
    {
        SecurityUtils.getUserId();
        return toAjax(bigScreenService.updateBigScreen(BigScreen.toBigScreen(bigScreen)));
    }

    /**
     * 删除大屏配置
     */
    @ApiOperation("删除大屏配置")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        SecurityUtils.getUserId();
        return toAjax(bigScreenService.deleteBigScreenByIds(ids));
    }
}
